home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / programming / other / gui4cli / dir / dir.g < prev    next >
Text File  |  1999-04-29  |  10KB  |  423 lines

  1. G4C  
  2.  
  3. ; This file contains the 3 pop-up on Right-Mouse-Button click GUIs.
  4.  
  5. ; ==================================================================
  6. ; The 1st RMB pop-up gui (name = dir.g)
  7. ; ==================================================================
  8.  
  9. WinBig 0 0 80 105 ""
  10. WinType 00001000
  11. winonmouse 30 22 
  12. varpath dir.gc
  13.  
  14. xOnRMB 
  15. guiclose Dir.g
  16.  
  17. xOnInactive
  18. guiclose Dir.g
  19.  
  20. xOnOpen                ; upon opening the window
  21. id = $$lv.id            ; get the listview's id
  22. if $id < 1
  23.    id = 1
  24. endif
  25. if $id = 2            ; set the copy/move gadgets pointing
  26.    setgad Dir.g 1 HIDE            ; correctly according to the LV's id.
  27.    setgad Dir.g 2 HIDE
  28.    setgad Dir.g 11 show
  29.    setgad Dir.g 22 show
  30.    destid  = 1              ; store destination lv id
  31. else
  32.    setgad Dir.g 11 HIDE
  33.    setgad Dir.g 22 HIDE
  34.    setgad Dir.g 1 show
  35.    setgad Dir.g 2 show
  36.    destid = 2
  37. endif
  38. redraw Dir.g
  39. lvuse dir.gc $destid        ; use the destination lv
  40. destdir = $$lv.dir        ; store the destination dir
  41. lvuse dir.gc $id        ; restore the source lv
  42.  
  43. ;=============================== Next GUI button
  44.  
  45. xbutton 0 0 0 15 More..
  46. guiopen Dir.g3            ; open an other gui with more options
  47. guiclose Dir.g
  48.  
  49. ;=============================== copy button
  50.  
  51. xbutton 0 15 0 15 Copy->
  52. gadhelp 'Copy files from LEFT to RIGHT listview'
  53. gadid 1
  54. gosub Dir.g copy
  55.  
  56. xbutton 0 15 0 15 <-Copy
  57. gadhelp 'Copy files from RIGHT to LEFT listview'
  58. gadid 11
  59. gosub Dir.g copy
  60.  
  61. xroutine copy
  62. guiclose Dir.g
  63. lvaction copy $destdir                  ; copy all selected files/dirs
  64. lvuse dir.gc $destid
  65. lvdir refresh                   ; refresh destination
  66.  
  67. ;============================= copy new files (same logic as copy)
  68.  
  69. xbutton 0 30 0 15 "Copy New"
  70. gadhelp 'Only copy newer files'
  71. guiclose Dir.g
  72. lvaction copynew $destdir        ; same as copy, above
  73. lvuse dir.gc $destid
  74. lvdir refresh
  75.  
  76. ;=============================== Move (same logic as copy)
  77.  
  78. xbutton 0 45 0 15 Move->
  79. gadhelp 'Move selected files'
  80. gadid 2
  81. gosub Dir.g move
  82.  
  83. xbutton 0 45 0 15 <-Move
  84. gadhelp 'Move selected files'
  85. gadid 22
  86. gosub Dir.g move
  87.  
  88. xroutine move
  89. guiclose Dir.g
  90. lvaction move $destdir
  91. lvuse dir.gc $destid
  92. lvdir refresh
  93.  
  94.  
  95. ;============================== delete
  96.  
  97. xbutton 0 60 0 15 Delete
  98. gadhelp 'Delete selected Files/Directories'
  99. guiclose Dir.g
  100. lvaction delete REQ
  101.  
  102.  
  103. ;============================= rename
  104. ; This routine reads the dir listview in the normal first/next method
  105. ; using the lvmulti command and passes the files to guis:tools/rtn/GetString
  106. ; GetString calls the routine "ren" for every file..
  107.  
  108. xbutton 0 75 0 15 Rename
  109. gadhelp 'Rename selected files'
  110. guiclose Dir.g
  111. lvuse dir.gc $id
  112. lvmulti first              ; get the first record
  113. renfile = $dir.gc/lv_file  ; store name to be safe
  114. if $renfile > ' '
  115.    guiload guis:tools/rtn/GetString "Rename $renfile :" "$renfile" dir.g ren multi
  116. endif
  117.  
  118. xRoutine ren newname
  119. rename $renfile $newname
  120. lvuse dir.gc $id
  121. lvmulti off
  122. extract newname file newname
  123. lvput $newname
  124. lvmulti next               ; get the next record
  125. renfile = $dir.gc/lv_file  
  126. if $renfile > ' '
  127.    guiload guis:tools/rtn/GetString "Rename $renfile :" "$renfile" dir.g ren multi
  128. else
  129.    lvdir refresh
  130.    guiquit GetString
  131. endif
  132.  
  133.  
  134. ;============================== makedir
  135.  
  136. xbutton 0 90 0 15 MakeDir
  137. gadhelp 'Create a Directory'
  138. tempdir = $$lv.dir
  139. if $tempdir[-1][1] = ":"     ; add the / if not a device
  140. or $tempdir[-2][2] = ':\"'   ; taking care of quotes
  141.    ;
  142. elseif $tempdir[-1][1] = '\"'
  143.    tempdir[-1][1] = '/'
  144.    appvar tempdir '\"'
  145. else
  146.    appvar tempdir '/'
  147. endif
  148. guiload guis:tools/rtn/GetString "Create Directory:" "$dir.g/tempdir" dir.g mkdir
  149.  
  150. xroutine mkdir     ; called by getstring as above
  151. makedir $$arg.0
  152. lvdir refresh      ; hoping it's still the same listview..
  153.  
  154.  
  155. ; ==================================================================
  156. ;###################################################################
  157. ; ==================================================================
  158. NEWFILE dir.g3    ; The more.. gui (from the RMB pop-up gui)
  159. ; ==================================================================
  160.  
  161.  
  162. WinBig 0 0 160 105 ""
  163. WinType 00001000
  164. winonmouse 50 8 
  165. varpath dir.gc/cli.gc/fsearch.gc
  166.  
  167. xOnRMB 
  168. guiclose Dir.g3
  169.  
  170. xOnInactive
  171. guiclose Dir.g3
  172.  
  173. xOnOpen
  174. id = $$LV.ID           ; Get the id of the current lvdir
  175.  
  176. xOnClose
  177. setwintitle dir.g3 ""     ; because ezreq will change the wintitle..
  178.  
  179.  
  180. ;================================ buttons (left bank)
  181.  
  182. xbutton 0 0 40 15  <<        ; previous
  183. guiopen dir.g
  184. guiclose dir.g3
  185.  
  186. xbutton 40 0 40 15  >>        ; next
  187. guiopen dir.g4
  188. guiclose dir.g3
  189.  
  190. xbutton 0 15 80 15 View
  191.   gadhelp 'View selected files according to their type'
  192.   guiclose dir.g3
  193.   ; look for a user-defined gui named "viewer.g"
  194.   extract dir.gc path dirpath
  195.   joinfile $dirpath "usr/viewer.g" viewgui
  196.   ifexists file $viewgui
  197.      guiload $viewgui dir.gc $id
  198.   else
  199.      lvuse dir.gc $id
  200.      lvmulti first
  201.      while $lv_file > ""
  202.         guiload guis:tools/rtn/getfiletype $dir.gc/lv_file
  203.         filetype = $$ret.0
  204.         if $filetype != NONE
  205.            guiload guis:tools/rtn/ViewFile $dir.gc/lv_file $dir.g3/filetype CLI
  206.         endif
  207.         lvmulti next
  208.      endwhile
  209.   endif
  210.  
  211.  
  212. xbutton 0 30 80 15 Protect
  213. gadhelp 'Protect selected files'
  214. guiclose dir.g3
  215. guiload  :dir.prot
  216. guiopen  dir.prot
  217.  
  218. xbutton 0 45 80 15 Size
  219. gadhelp 'Show & sum size of selected items'
  220. guiclose dir.g3
  221. lvuse dir.gc $id
  222. lvaction SIZE lv_size
  223. SetWinTitle dir.gc '$lv_size bytes of $$lv.dir'
  224.  
  225. xbutton 0 60 80 15 Assign
  226. gadhelp 'Assign Current directory'
  227. tempdir = $$lv.dir
  228. guiclose dir.g3
  229. guiload guis:tools/rtn/GetString "Assign $dir.g3/tempdir as:" "" dir.g3 asn
  230.  
  231. xroutine asn        ; called by getstring as above
  232. assign $$arg.0 $tempdir
  233.  
  234. xbutton 0 75 80 15 'CliGui'
  235. gadhelp 'Open Guis:tools/cli.gc'
  236. cd $$lv.dir
  237. guiclose dir.g3
  238. guiload guis:tools/cli.gc  "" CLI  ; will open itself
  239.  
  240. xbutton 0 90 80 15 Shell
  241. gadhelp 'Open a new Shell'
  242. guiclose dir.g3
  243. cd $$LV.DIR
  244. run 'newshell $$g4c.output'
  245.  
  246.  
  247. ; ------------------ Buttons right bank
  248.  
  249. xbutton 80  0 80 15 User..
  250. gadhelp 'Open the Dir/Dir.user pop-up gui'
  251. guiload :dir.user
  252. guiclose dir.g3
  253.  
  254. xbutton 80 15 80 15 Search
  255. gadhelp 'Search for files and/or text in current dir'
  256. guiclose dir.g3
  257. ; store it here, because gui has lv and will loose it..
  258. spath = $$lv.dir
  259. guiload guis:g4c/fsearch/fsearch.gc $dir.g3/spath
  260.  
  261. xbutton 80 30 80 15 Replace
  262. gadhelp 'Replace text in selected files'
  263. guiclose dir.g3
  264. guiload  :dir.rep
  265. guiopen  dir.rep
  266.  
  267. xbutton 80 45 80 15 ReWrap
  268. gadhelp 'Re-Wrap selected files'
  269. guiclose dir.g3
  270. guiload :dir.wrap
  271.  
  272. xbutton 80 60 80 15 "AddIcon"
  273. gadhelp 'Add icons (if icon for file type exists in guis:tools/icons/def)'
  274. guiclose dir.g3
  275. lvuse dir.gc $id
  276. lvmulti first
  277. while $lv_file > ''
  278.    if $lv_file[-1][1] = '\"'  ; care for possible quotes
  279.       fname = $lv_file
  280.       fname[-1][1] = '.'
  281.       fname = '$fname\info\"'
  282.    else
  283.       fname = $lv_file\.info
  284.    endif
  285.    if $$lv.type == DIR
  286.       copy guis:tools/icons/def/DRAWER.info $fname
  287.    else
  288.       guiload guis:tools/rtn/getfiletype $dir.gc/lv_file
  289.       filetype = $$ret.0
  290.       infoname = "guis:tools/icons/def/$filetype\.info"
  291.       ifexists file $infoname
  292.          copy $infoname $fname
  293.       endif
  294.    endif
  295.    lvmulti off
  296.    lvmulti next
  297. endwhile
  298. lvdir refresh
  299.  
  300. xbutton 80 75 80 15 "Select"
  301. guiload guis:tools/rtn/GetString "Enter substring to select:" "" dir.g3 select
  302.  
  303. xroutine select     ; called by select as above
  304. guiclose dir.g3
  305. pat = $$arg.0
  306. lvsearch '$pat' ci first
  307. while $$lv.line > ''
  308.    lvmulti on
  309.    lvsearch '$pat' ci next
  310. endwhile
  311.  
  312.  
  313. xbutton 80 90 80 15 ""
  314.  
  315.  
  316.  
  317. ;#########################################################################
  318.  
  319. ; ==================================================================
  320. NEWFILE dir.g4    ; The more->more.. gui (from the RMB pop-up gui)
  321. ; ==================================================================
  322.  
  323. WinBig 0 0 160 105 ""
  324. WinType 00001000
  325. winonwin Dir.g3 0 0 
  326. varpath dir.gc
  327.  
  328. xOnRMB 
  329. guiclose Dir.g4
  330.  
  331. xOnInactive
  332. guiclose Dir.g4
  333.  
  334.  
  335. ;================================ buttons (left bank)
  336.  
  337. xbutton 0 0 80 15  <<
  338. guiopen dir.g3
  339. guiclose dir.g4
  340.  
  341. xbutton 0 15 80 15 Calc
  342. gadhelp 'Load Guis:tools/calc.gc'
  343. guiclose dir.g4
  344. guiload guis:tools/calc.gc
  345.  
  346. xbutton 0 30 80 15 Lock
  347. gadhelp 'Load Guis:tools/lock.gc'
  348. guiclose dir.g4
  349. guiload :dir.lock
  350.  
  351. xbutton 0 45 60 15 PPShow
  352. gadhelp 'View selected files using c:ppshow'
  353. guiclose dir.g4
  354. guiload :dir.ppshow
  355.  
  356. xbutton 60 45 20 15 ?
  357. gadhelp 'Open Gui for the PPShow graphics player'
  358. guiclose dir.g4
  359. guiload :dir.ppshow
  360.  
  361. xbutton 0 60 80 15 'Palette'
  362. gadhelp 'Opens the Palette gui'
  363. guiclose dir.g3
  364. guiload  guis:tools/palette.gc
  365.  
  366. xbutton 0 75 80 15 GfxCon
  367. gadhelp 'Opens gui for GfxCon picture converter'
  368. guiclose dir.g4
  369. guiload :dir.gfxcon
  370.  
  371. xbutton 0 90 80 15 Avail
  372. gadhelp 'Opens Gui for showing memory usage'
  373. guiclose dir.g4
  374. guiload :dir.avail
  375.  
  376. ; ------------------ Buttons right bank
  377.  
  378. xbutton 80  0 80 15 'LHa Pack'
  379. gadhelp 'Pack Selected files with LhA'
  380. guiclose dir.g4
  381. guiload :dir.lha
  382.  
  383. xbutton 80 15 80 15 'XPK'
  384. gadhelp 'Load gui for XPK packers'
  385. guiclose dir.g4
  386. guiload :dir.xpack
  387.  
  388. xbutton 80 30 80 15 "ZIP"
  389. gadhelp 'Pack Selected files with ZIP'
  390. guiclose dir.g4
  391. guiload :dir.zip
  392.  
  393. xbutton 80 45 80 15 "GuiEdit"    ; start up a gui editor kind of thing..
  394. gadhelp "Open gui with gadgets for copying (it'll get better..)"
  395. guiclose dir.g4
  396. guiload guis:tools/guiedit.gc
  397. guiopen guiedit.gc
  398.  
  399. xbutton 80 60 80 15 Config
  400. gadhelp 'Loads the configuration gui'
  401. guiclose dir.g4
  402. guiload guis:tools/config.gc
  403.  
  404. xbutton 80 75 80 15 Help
  405. gadhelp 'Loads the dir.gc guide'
  406. extract dir.gc guipath lv_path
  407. joinfile $lv_path dir.guide lv_guide
  408. run '$*DEF.GUIDE $lv_guide'
  409. delvar lv_path
  410. delvar lv_guide
  411.  
  412. xbutton 80 90 80 15 Quit
  413. guiclose dir.g4
  414. ezreq "QUIT ???!!..\nWho, me ?\n" 'DIE!|Well..' lv_ask
  415. if $lv_ask = 1
  416.    guiquit dir.gc
  417. endif
  418.  
  419. ; the pop-up on double-click guis have been moved to file guis:dir/dir.g2
  420.  
  421.  
  422.  
  423.